import { createStore } from 'vuex';
import orderModule from './modules/order'

export default createStore({
    state: {
        isLoggedIn: false,
        username: '',
    },
    mutations: {
        setLoggedIn(state, status) {
            state.isLoggedIn = status;
        },
        setUsername(state, username) {
            state.username = username;
        },
    },
    actions: {
        login({ commit }, { username }) {
            commit('setLoggedIn', true);
            commit('setUsername', username);
        },
        logout({ commit }) {
            commit('setLoggedIn', false);
            commit('setUsername', '');
        },
    },
    modules: {
        order: orderModule // 注册order模块
    },
});
